home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: undergrad.math.uwaterloo.ca!news
- From: Jose Felix Sandoval <jfsandov>
- Subject: Re: Help on random numbers
- Sender: news@undergrad.math.uwaterloo.ca (news spool owner)
- Message-ID: <DMD3oo.1CF@undergrad.math.uwaterloo.ca>
- Date: Tue, 6 Feb 1996 16:12:24 GMT
- X-Url: news:4f7193$4bi@jaring.my
- Content-Transfer-Encoding: 7bit
- Content-Type: text/plain; charset=us-ascii
- References: <4f7193$4bi@jaring.my>
- Nntp-Posting-Host: zeno01.math.uwaterloo.ca
- Mime-Version: 1.0
- X-Mailer: Mozilla 1.12 (X11; I; AIX 2)
- Organization: University of Waterloo
-
- Use the time() function in the srand() function.
- i.e.
- for ( i = 0; i<10; i++ ) {
- delay(1000); <- Clock is too fast...
- srand(time(NULL));
- cout << rand() % 10;
- }
-
- Will give 10 random numbers from 0 - 9...
-
- --
- Jose Sandoval | jfsandov@uwaterloo.ca
-
-